perm filename EMAIN3.2[EAL,HE]1 blob sn#676499 filedate 1982-09-27 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Editor:  Editor-command executor }
C00005 00003	procedure eDoECmd (var okp: boolean) external
C00009 ENDMK
CāŠ—;
{$NOMAIN	Editor:  Editor-command executor }

%include emain.hdr;

{ Externally defined routines from elsewhere: }

	(* From EAUX2C *)
procedure setECurInt;						external;

	(* From EAUX3A *)
procedure mark;							external;
procedure unmark(all: boolean);					external;
procedure saveOutermostEnv;					external;
procedure flushOldEnvironments(dLev: integer);			external;
procedure writeProg;						external;
procedure readProg;						external;
procedure getEcmd;						external;
function atStmnt: boolean;					external;
procedure doSetcmd;						external;

	(* From EAUX3B *)
procedure varDefine;						external;
procedure setBpt(st: statementp);				external;
procedure clrBpt(st: statementp);				external;
procedure clrAllBpts;						external;
procedure setTBpt(st: statementp);				external;
procedure stepStmnt(bpttype: integer);				external;
procedure trace(all: boolean);					external;

	(* From EDEBUG *)
procedure runStmnt(which: integer);				external;
procedure executeStmnt(st: statementp; which: integer);		external;
procedure goStmnt(which: integer);				external;

	(* From PP *)
procedure ppLine; 						external;
procedure ppOutNow; 						external;
procedure ppChar(ch: ascii); 					external;
procedure pp5(ch: c5str; length: integer); 			external;
procedure pp10(ch: cstring; length: integer); 			external;
procedure pp10L(ch: cstring; length: integer);			external;
procedure pp20(ch: c20str; length: integer); 			external;
procedure pp20L(ch: c20str; length: integer); 			external;


procedure em3Get; external;
procedure em3Get; begin end;
procedure eDoECmd (var okp: boolean); external;
procedure eDoECmd ;
 begin
 with eCurToken do
	 case ed of
savecmd:    writeProg;		(* Write out program to file *)
getcmd:     readProg;		(* Read in new program from file *)
definecmd:  varDefine;		(* write Definitions for the specified vars *)
(* insertcmd,renamecmd... *)
setcmd:	    doSetcmd;		(* change appropriate system var *)
markcmd:    mark;
unmarkcmd:  begin
	    getEcmd;
	    if (ttype = reswdtype) and (rtype = filtype) and
	       (filler = alltype) then unmark(true) else unmark(false);
	    end;
		(* debugger commands follow *)
popcmd:	    begin
	    if debugLevel = 0 then
	      begin
	(* *** probably should ask if luser wants to zero or save	*** *)
	(* *** the variables in outermost environment.			*** *)
	(* *** if zeroing then 					 	*** *)
	(* ***   begin flushOldEnvironments(0); initOuterBlock end	*** *)
	(* ***  else							*** *)
	      saveOutermostEnv;
	      end
	     else flushOldEnvironments(debugLevel);	(* pop up a level *)
	    setECurInt;
	    end;
tracecmd:   begin
	    getEcmd;
	    if (ttype = reswdtype) and (rtype = filtype) and
	       (filler = alltype) then trace(true) else trace(false);
	    end;
breakcmd:   if atStmnt then setBpt(cursorStack[cursor].st);	(* ok to set it *)
unbreakcmd: begin
	    getEcmd;
	    if (ttype = reswdtype) and (rtype = filtype) and
	       (filler = alltype) then clrAllBpts
	     else
	      if atStmnt then clrBpt(cursorStack[cursor].st);  (* ok to clear it *)
	    end;
tbreakcmd:  begin
	    if atStmnt then			(* ok to set breakpoint? *)
	      begin
	      setTBpt(cursorStack[cursor].st);	(* put a temporary one there *)
	      runStmnt(3);			(* & proceed with program *)
	      end
	    end;
stepcmd:    begin stepStmnt(1); runStmnt(3); end;
sstepcmd:   begin stepStmnt(2); runStmnt(3); end;
nstepcmd:   begin stepStmnt(3); runStmnt(3); end;
gstepcmd:   begin stepStmnt(4); runStmnt(3); end;
proceedcmd: runStmnt(3);		(* Proceed with program *)
gocmd:	    if atStmnt then goStmnt(3);	(* Jump to current cursor location *)
executecmd: if atStmnt then executeStmnt(cursorStack[cursor].st,3);
	    (* Execute statement at current cursor location *)
startcmd:   begin
	    saveOutermostEnv;		(* reset Interpreter *)
	    runStmnt(3);		(* Start program from the top *)
	    end;
otherwise   begin			(* ??? *)
	    pp20L(' unknown command    ',17); ppLine;
	    okp := false;
	    end;
	 end
 end;